﻿


#region Using Statements

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using System.Threading;
using System.ComponentModel;
using System.Reflection;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Design;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

using Freeform;
using FGame = Freeform.Game;
using XGame = Microsoft.Xna.Framework.Game;
using FComponent = Freeform.Component;

#endregion


namespace Client
{
    public class Test2D : World
    {
        /* Game World.
         * Day/Night pair of Terrain maps with doodads.
         * Map switches to night time map at the start of a round and start zombie spawning.
         * Map switches to day time map at the end of a round and open rpg upgrading menus.
         * Player turret.
         * Attack wave(s) spawning/attacking moving.
         * Victory/Defeat conditions.
         * Mouse Cursor handling/re-texturing.
         * Turret Firing and Damage/Splash/DoT application.
         * 
         * Explosion Projectile & other special effect classes will be probably applied here.
        */

        #region Members

        public Viewport2D View { get; set; }

        public TileLevelDrawEntity Map { get; set; }

        public Entity2D CameraTarget { get; set; }

        KeyboardState kState { get; set; }
        #endregion


        #region Initialisation

        public Test2D(IGame Game)
            : base(Game)
        {
            BackgroundColour = Color.CadetBlue;

            CameraTarget = new Entity2D(this);

            Map = new TileLevelDrawEntity(this, Game.Content.Load<TileMap2D>("Levels/test1"));
            Map.Depth = 0.44f;

            View = new Viewport2D(this);
            View.DebugFont = Game.Content.Load<SpriteFont>("Fonts/Plain");
            View.DebugText = "Testing..";
            View.DebugColour = Color.White;
            View.ColourOverlay = Color.White;
            View.Depth = 0.8f;

            View.Camera.Position = new Vector2(0, 0);
            View.Camera.Size = new Vector2(700, 700);
            //View.Camera.CentreCamera(Map.Position);
        }

        #endregion


        public override void Update(GameTime Time)
        {
            base.Update(Time);
            kState = Keyboard.GetState();

            View.Camera.CentreCamera(CameraTarget.Position);

            if(kState.IsKeyDown(Keys.W))
                CameraTarget.Position += new Vector2(0,-4);
            if (kState.IsKeyDown(Keys.S))
                CameraTarget.Position -= new Vector2(0, -4);
            if (kState.IsKeyDown(Keys.A))
                CameraTarget.Position += new Vector2(-4, 0);
            if (kState.IsKeyDown(Keys.D))
                CameraTarget.Position -= new Vector2(-4, 0);

            if (kState.IsKeyDown(Keys.Q))
                Map.Size += new Vector2(0.5f, 0.5f);
            if (kState.IsKeyDown(Keys.E))
                Map.Size -= new Vector2(0.5f, 0.5f);

            View.DebugText = Map.Size.ToString();
        }

    }
}